package org.jackysoft.util;

import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.util.List;




import org.jackysoft.annotations.Id;

import com.google.common.collect.Lists;

public class AnnotationUtil {
	public static String getPKFieldName(Class<?> type) {
		if (type.isAnnotationPresent(Id.class)) {
			Id id = type.getAnnotation(Id.class);

		}
		return null;
	}

	/***/
	public static String[] getAnnotationPresentedProperties(Object obj,
			Class<NoSerialize> als) {
		Class<?> c = obj.getClass();
		List<String> pnames = Lists.newArrayList();
		Field[] fds = c.getFields();
		for (Field f : fds) {
			if (!f.isAnnotationPresent(als)) {
				pnames.add(f.getName());
			}
		}
		String[] ps = new String[pnames.size()];
		pnames.toArray(ps);
		return ps;
	}

	public static <A extends Annotation> A getAnnotation(Class<?> targetClass,
			Class<A> anoClass) {
		if (targetClass == null)
			throw new java.lang.IllegalArgumentException("targetClass 对象不能为空");
		if (anoClass == null)
			throw new java.lang.IllegalArgumentException(
					"annotationClass 对象不能为空");
		A a = targetClass.getAnnotation(anoClass);
		return a;

	}

}
